package com.pubinfo.passbook.common.model.dto.open;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.pubinfo.passbook.common.model.ruler.UserAcc;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Data
@ApiModel(value = "WiteoffData", description = "报账单数据")
public class WiteoffData implements Serializable {
  public static final long serialVersionUID = 7424497997148290435L;
  @ApiModelProperty(value = "外围系统主单唯一标志，每次报账都必须是唯一，不允许重复.", hidden = true)
  public String otherSystemMainId;
  
  @ApiModelProperty(value = "调用方系统编码 必须", required = true)
  @NotNull
  @JsonIgnore
  public String systemCode;
  @ApiModelProperty(value = "流程编码 SFPTFQJT-CSKJ_02 直接到费用会计  SFPTFQJT-CSKJ_02_EPP 到分公司稽核会计", required = true)
  @NotNull
  @JsonIgnore
  private String processCode;
  @ApiModelProperty(value = "报账人账号 集团统一用户目录账号（全国唯一） 必须", required = true)
  @NotNull
  public String account;
  @ApiModelProperty(value = "报账人姓名 系统通过调用财辅系统获取 必须", hidden = true)
  public String fillInName;
  @ApiModelProperty(value = "报账组织编码 可以通过“获取报账组织信息”接口获取 必须 需要财智送")
  public String fillInOrgCode;
  @ApiModelProperty(value = "公司代码 必须", hidden = true)
  public String sapCompayCode = "A011";
  @ApiModelProperty(value = "经济事项编码 必须", hidden = true)
  public String economicItemCode = "10040805";
  @ApiModelProperty(value = "经济事项名称 必须", hidden = true)
  public String economicItemName = "车辆使用";
  @ApiModelProperty(value = "收支方式 选项：1 已支付-委托银行划扣-本地划扣\n" +
      "2 已支付-本地已主动支付\n" +
      "3 已支付-委托银行划扣-集中划扣\n" +
      "4 涉及付款-银行支付-集中支付\n" +
      "5 涉及付款-商业汇票-汇票支付\n" +
      "6 涉及收款-本地收款\n" +
      "7 涉及收款-集中收款\n" +
      "8 不涉及收付  必须   银行扣款挂账送2\n" +
      "发票挂账和往来转销送5", required = true)
  @NotNull
  public String paymentType;
  
  @ApiModelProperty(value = "如果选择一单清模式,则传1", hidden = true)
  public String singleClearFlag = "1";
  @ApiModelProperty(value = "费用发生日 必须 格式为：YYYY-MM-DD 必须", required = true)
  @JsonFormat(pattern = "yyyy-MM-dd")
  @NotNull
  public String happenDate;
  @ApiModelProperty(value = "报账期间  格式必为：YYYY-MM 必须", required = true)
  @NotNull
  public String budgetSet;
  @ApiModelProperty(value = "业务类型 选项：0-列账，1-付款,2-列并付 必须", hidden = true)
  public String bizType = "0";
  @ApiModelProperty(value = "会计科目编码 非必须 可从SAP获取基础数据 银行扣款挂账=委托划扣银行账号对应的会计科目编码；\n" +
      "发票挂账&往来转销=G000343924", hidden = true)
  public String accountCode;
  @ApiModelProperty(value = "会计科目名称 非必须 根据accountCode从主数据取", hidden = true)
  public String accountName;
  @ApiModelProperty(value = "科目类型 非必须 选输(1-总账、2-供应商、3-客户),有科目时必须  银行扣款挂账=1 发票挂账&往来转销=2", hidden = true)
  public String accountType;
  
  @ApiModelProperty(value = "是否员工代垫 必须 如不涉及银行支付，请提供空值," +
      " 选项：0-否，1-是  <br/> ", hidden = true)
  public Integer isStaffPayment = 0;
  @ApiModelProperty(value = "业务编码类型 非必须 选项 1-合同  3-采购订单号  5-框架汇总单号 如果为空，而且合同编码/业务编码字段又存在，则默认为1-合同", hidden = true)
  public Integer bizCodeType;
  @ApiModelProperty(value = "合同编码/业务编码", hidden = true)
  public String contractNo;
  @ApiModelProperty(value = "合同名称/业务名称", hidden = true)
  public String contractName;
  @ApiModelProperty(value = "报账金额 必须 子单总金额必需等于报账金额 必须", required = true)
  @NotNull
  public BigDecimal sum;
  @ApiModelProperty(value = "说明 ")
  public String desc;
  
  @ApiModelProperty(value = "票据类型 非必须 当集成业务涉及增值税时，必须。 选项：" +
      "1-增值税专用发票，2-增值税普通发票，3-营业税发票，4-货物运输专用发票，" +
      "5-机动车销售统一发票，6-海关进口增值税专用缴款书，8-普通收据，9无发票，" +
      "10-国外发票（国外账单），11-代扣代缴税收通用缴款书，12-电子发票-普票，" +
      "13-增值税专用发票（免税高新企业），14-通行费电子发票，15-通用发票" +
      "目前这些选项中省系统只要提供“12-电子发票-普票”这一种票据类型，15-通用发票 19-财政电子票据。 必须  银行扣款挂账和往来转销默认9，发票挂账默认14", required = true)
  @NotNull
  public Integer invoiceType;
  @ApiModelProperty(value = "是否需要手工扫描 必须 0-否，1-是 必须", hidden = true)
  public Integer isNeedImage = 0;
  @ApiModelProperty(value = "是否调用预算  非必须  " +
      "0:不调用 1：调用(默认) 空：" +
      "通过经济事项+省级编码+外围系统标识到配置表进行查找", hidden = true)
  public Integer isBudget = 0;
  
  @ApiModelProperty(value = "是否存在实物赠送\t营改增业务必填\t是否存在实物赠送 1：是0:否 实物", hidden = true)
  private Integer isRealGift;
  @ApiModelProperty(value = "精确到2位小数点\t实付金额", hidden = true)
  private BigDecimal actualPaidSum;
  @ApiModelProperty(value = "精确到2位小数点\t实物赠送税额\t营改增业务必填", hidden = true)
  private BigDecimal realGiftTaxSum;
  
  /**
   * 报账子单信息集合
   */
  @ApiModelProperty(value = "报账子单信息集合", required = true)
  List<WiteoffSubitemData> lineItems = new ArrayList<>();
  
  @ApiModelProperty(value = "精确到2位小数点\t实物赠送金额\t营改增业务必填", hidden = true)
  private BigDecimal realGiftSum;
  @ApiModelProperty(value = "业务发生时间点标志\t营改增业务必填\t业务发生时间  ", hidden = true)
  private Integer businessHappenTimeFlag;
  @ApiModelProperty(value = "纳税属性\t非必须\t1-属地纳税、2-汇总纳税、3-汇总传统，根据经济事项         配置的数据默认推导", hidden = true)
  private Integer payTaxAttribute;
  @ApiModelProperty("业务场景（挑对模式）\n" +
      "0:其他\n" +
      "1:冲前期借款（冲预付款）\n" +
      "2:挂账后付款（清偿应付款）\n" +
      "3:冲预列（冲暂估）\n" +
      "4:收回应收款（收回保证金、押金等）\n" +
      "5:往来转销\n" +
      "6:其它收款\n" +
      "7:挂账不付款（含预列）\n" +
      "8:预付款\n" +
      "9:挂账并付款\n" +
      "A:借款  银行扣款挂账送8预付款\n" +
      "发票挂账送7挂账不付款\n" +
      "往来转销送5")
  //8:预付款  //银行扣款挂账
  //7挂账不付款 //发票挂账
  //5:往来转销
  private Integer pickingMode;
  @ApiModelProperty(value = "默认CNY 枚举项：  CNY HKD  JPY USD 非必须", hidden = true)
  private String currency;
  
  @ApiModelProperty(value = "特殊总账标识 非必须", hidden = true)
  private String specialTag;
  
  @ApiModelProperty("备选统驭科目编码 非必须")
  private String preAccountCode;
  
  @ApiModelProperty("备选统驭科目名称 非必须")
  private String preAccountName;
  
  @ApiModelProperty(value = "是否付款\t非必须\t0-否，1-是，2-其他 非必须", hidden = true)
  private Integer isPayment;
  @ApiModelProperty(value = "是否加急\t非必须\t0-否，1-是 非必须", hidden = true)
  private Integer isEmergency;
  
  @ApiModelProperty(value = "是否涉及进项税转出\t非必须\t0-否，1-是 非必须", hidden = true)
  private Integer isInputTax = 0;
  
  @ApiModelProperty(value = "进项税转出税额\t非必须\t是否进项税转出为是时必输 精确到2位小数点 非必须", hidden = true)
  private BigDecimal inputTaxTurnSum;
  
  @ApiModelProperty(value = "进项税转出业务类型\t非必须\t1：免税项目  2：非免税项目 非必须", hidden = true)
  private Integer inputTaxTurnBizType;
  
  @ApiModelProperty(value = "往来类型编码 非必须", hidden = true)
  private String contactDetailInfoCode;
  
  @ApiModelProperty(value = "往来类型名称 非必须", hidden = true)
  private String contactDetailInfoName;
  
  @ApiModelProperty("委托划扣银行账号 非必须")
  private String delegationBankCode;
  
  @ApiModelProperty(value = "关联交易类型编码 非必须", hidden = true)
  private String relativeTypeCode;
  
  @ApiModelProperty(value = "关联交易类型名称 非必须", hidden = true)
  private String relativeTypeName;
  
  @ApiModelProperty(value = "发票稽核\t非必须\t当为1时，该集成单据稽核且稽核结果为“稽核通过”； 当为0时，该集成单据稽核且稽核结果为“稽核不通过” 非必须", hidden = true)
  private Integer invoiceCheck;
  @ApiModelProperty(value = "是否反记账\t可选\t1：是 非必须", hidden = true)
  private Integer isOppositeLedger;
  @ApiModelProperty(value = "单据是否需要后续补充材料归档\t 0否1是2事后补票 ,不送默认为否 非必须", hidden = true)
  private Integer isArchive;
  
  @ApiModelProperty(value = "关联供应商集合 当“业务类型”为1，2时，且“是否员工代垫”为0时，必须")
  public List<WiteoffRelateSupplier> relateSuppliers = new ArrayList<>();
  
  //  @ApiModelProperty(value = "收款方信息集合 当“业务类型”为1，2时，要")
//  public List<TWiteoffPayMent> payMentItems = new ArrayList<>();
  
  @ApiModelProperty("关联发票集合")
  public List<WiteoffInvoiceInfo> invoiceInfos = new ArrayList<>();
  @ApiModelProperty(value = "报账审核资料集合")
  public List<WiteoffAttchment> attchmentAdds = new ArrayList<>();
  @ApiModelProperty(value = "挑对记录 当业务场景是1、2、3时，要")
  public List<WiteoffOpenPicking> openItemPickings = new ArrayList<>();
  
  //  @ApiModelProperty(value = "共享附件信息集合 当业务场景是1、2、3时，要")
//  public List<TWiteoffShareAttachment> shareAttachmentItems = new ArrayList<>();
//
  @JacksonXmlProperty(localName = "account")
  public String getAccount() {
    return account;
  }
  
  @JacksonXmlProperty(localName = "fillInName")
  public String getFillInName() {
    return fillInName;
  }
  
  @JacksonXmlProperty(localName = "fillInOrgCode")
  public String getFillInOrgCode() {
    return fillInOrgCode;
  }
  
  @JacksonXmlProperty(localName = "sapCompayCode")
  public String getSapCompayCode() {
    return sapCompayCode;
  }
  
  @JacksonXmlProperty(localName = "economicItemCode")
  public String getEconomicItemCode() {
    return economicItemCode;
  }
  
  @JacksonXmlProperty(localName = "economicItemName")
  public String getEconomicItemName() {
    return economicItemName;
  }
  
  @JacksonXmlProperty(localName = "paymentType")
  public String getPaymentType() {
    return paymentType;
  }
  
  @JacksonXmlProperty(localName = "happenDate")
  public String getHappenDate() {
    return happenDate;
  }
  
  @JacksonXmlProperty(localName = "budgetSet")
  public String getBudgetSet() {
    return budgetSet;
  }
  
  @JacksonXmlProperty(localName = "bizType")
  public String getBizType() {
    return bizType;
  }
  
  @JacksonXmlProperty(localName = "accountCode")
  public String getAccountCode() {
    return accountCode;
  }
  
  @JacksonXmlProperty(localName = "accountName")
  public String getAccountName() {
    return accountName;
  }
  
  @JacksonXmlProperty(localName = "accountType")
  public String getAccountType() {
    return accountType;
  }
  
  @JacksonXmlProperty(localName = "isStaffPayment")
  public Integer getIsStaffPayment() {
    return isStaffPayment;
  }
  
  @JacksonXmlProperty(localName = "bizCodeType")
  public Integer getBizCodeType() {
    return bizCodeType;
  }
  
  @JacksonXmlProperty(localName = "contractNo")
  public String getContractNo() {
    return contractNo;
  }
  
  @JacksonXmlProperty(localName = "contractName")
  public String getContractName() {
    return contractName;
  }
  
  @JacksonXmlProperty(localName = "sum")
  public BigDecimal getSum() {
    return sum;
  }
  
  @JacksonXmlProperty(localName = "desc")
  public String getDesc() {
    return desc;
  }
  
  @JacksonXmlProperty(localName = "invoiceType")
  public Integer getInvoiceType() {
    return invoiceType;
  }
  
  @JacksonXmlProperty(localName = "isBudget")
  public Integer getIsBudget() {
    return isBudget;
  }
  
  @JacksonXmlProperty(localName = "otherSystemMainId")
  public String getOtherSystemMainId() {
    return otherSystemMainId;
  }
  
  @JacksonXmlProperty(localName = "singleClearFlag")
  public String getSingleClearFlag() {
    return singleClearFlag;
  }
  
  @JacksonXmlProperty(localName = "isNeedImage")
  public Integer getIsNeedImage() {
    return isNeedImage;
  }
  
  @JacksonXmlProperty(localName = "isRealGift")
  public Integer getIsRealGift() {
    return isRealGift;
  }
  
  @JacksonXmlProperty(localName = "actualPaidSum")
  public BigDecimal getActualPaidSum() {
    return actualPaidSum;
  }
  
  @JacksonXmlProperty(localName = "realGiftTaxSum")
  public BigDecimal getRealGiftTaxSum() {
    return realGiftTaxSum;
  }
  
  @JacksonXmlElementWrapper(localName = "lineItems")
  @JacksonXmlProperty(localName = "lineItem")
  public List<WiteoffSubitemData> getLineItems() {
    return lineItems;
  }
  
  @JacksonXmlProperty(localName = "realGiftSum")
  public BigDecimal getRealGiftSum() {
    return realGiftSum;
  }
  
  @JacksonXmlProperty(localName = "currency")
  public String getCurrency() {
    return currency;
  }
  
  @JacksonXmlProperty(localName = "specialTag")
  public String getSpecialTag() {
    return specialTag;
  }
  
  @JacksonXmlProperty(localName = "preAccountCode")
  public String getPreAccountCode() {
    return preAccountCode;
  }
  
  @JacksonXmlProperty(localName = "preAccountName")
  public String getPreAccountName() {
    return preAccountName;
  }
  
  @JacksonXmlProperty(localName = "isPayment")
  public Integer getIsPayment() {
    return isPayment;
  }
  
  @JacksonXmlProperty(localName = "isInputTax")
  public Integer getIsInputTax() {
    return isInputTax;
  }
  
  @JacksonXmlProperty(localName = "inputTaxTurnSum")
  public BigDecimal getInputTaxTurnSum() {
    return inputTaxTurnSum;
  }
  
  @JacksonXmlProperty(localName = "inputTaxTurnBizType")
  public Integer getInputTaxTurnBizType() {
    return inputTaxTurnBizType;
  }
  
  @JacksonXmlProperty(localName = "contactDetailInfoCode")
  public String getContactDetailInfoCode() {
    return contactDetailInfoCode;
  }
  
  @JacksonXmlProperty(localName = "contactDetailInfoName")
  public String getContactDetailInfoName() {
    return contactDetailInfoName;
  }
  
  @JacksonXmlProperty(localName = "relativeTypeCode")
  public String getRelativeTypeCode() {
    return relativeTypeCode;
  }
  
  @JacksonXmlProperty(localName = "relativeTypeName")
  public String getRelativeTypeName() {
    return relativeTypeName;
  }
  
  @JacksonXmlProperty(localName = "isOppositeLedger")
  public Integer getIsOppositeLedger() {
    return isOppositeLedger;
  }
  
  @JacksonXmlProperty(localName = "isArchive")
  public Integer getIsArchive() {
    return isArchive;
  }
  
  @JacksonXmlProperty(localName = "businessHappenTimeFlag")
  public Integer getBusinessHappenTimeFlag() {
    return businessHappenTimeFlag;
  }
  
  @JacksonXmlProperty(localName = "payTaxAttribute")
  public Integer getPayTaxAttribute() {
    return payTaxAttribute;
  }
  
  @JacksonXmlProperty(localName = "pickingMode")
  public Integer getPickingMode() {
    return pickingMode;
  }
  
  @JacksonXmlProperty(localName = "isEmergency")
  public Integer getIsEmergency() {
    return isEmergency;
  }
  
  @JacksonXmlProperty(localName = "delegationBankCode")
  public String getDelegationBankCode() {
    return delegationBankCode;
  }
  
  @JacksonXmlProperty(localName = "invoiceCheck")
  public Integer getInvoiceCheck() {
    return invoiceCheck;
  }
  
  @JacksonXmlElementWrapper(localName = "relateSuppliers")
  @JacksonXmlProperty(localName = "relateSupplier")
  public List<WiteoffRelateSupplier> getRelateSuppliers() {
    return relateSuppliers;
  }

//  @JacksonXmlElementWrapper(localName = "payMentItems")
//  @JacksonXmlProperty(localName = "payMentItem")
//  public List<TWiteoffPayMent> getPayMentItems() {
//    return payMentItems;
//  }

//  @JacksonXmlElementWrapper(localName = "invoiceInfos")
//  @JacksonXmlProperty(localName = "invoiceInfo")
//  public List<WiteoffInvoiceInfo> getInvoiceInfos() {
//    return invoiceInfos;
//  }
  
  @JacksonXmlElementWrapper(localName = "attchmentAdds")
  @JacksonXmlProperty(localName = "attchmentAdd")
  public List<WiteoffAttchment> getAttchmentAdds() {
    return attchmentAdds;
  }
  
  @JacksonXmlElementWrapper(localName = "openItemPickings")
  @JacksonXmlProperty(localName = "openItemPicking")
  public List<WiteoffOpenPicking> getOpenItemPickings() {
    return openItemPickings;
  }
  
  //  @JacksonXmlElementWrapper(localName = "shareAttachmentItems")
//  @JacksonXmlProperty(localName = "shareAttachmentItem")
//  public List<TWiteoffShareAttachment> getShareAttachmentItems() {
//    return shareAttachmentItems;
//  }
  public WiteoffData() {
  
  }
  
  public void setUserAcc(UserAcc userAcc) {
    this.account = userAcc.getAccount();
    this.fillInName = userAcc.getName();
    //  this.fillInOrgCode = userAcc.getOrgCode();
    
  }
  
}
